package com.peng.servlet;

import com.alibaba.fastjson.JSON;
import com.peng.dao.impl.regionDaoImpl;
import com.peng.dao.regionDao;
import com.peng.entity.region;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * Created by 欧阳欣鹏 on 2018/8/16.
 */
public class FindRegionNameServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setContentType("text/html;charset=utf-8");
        request.setCharacterEncoding("utf-8");
        PrintWriter out = response.getWriter();
        int i = Integer.parseInt(request.getParameter("pro"));
        region r = new region();
        regionDao rdao = new regionDaoImpl();
        r = rdao.findregioname(i);
        String json= JSON.toJSONString(r);
        out.print(json);
        out.flush();
        out.close();

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }
}
